package com.woshua.tabmodel.fragment;

import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/*
* TabFragment
* */
public class TabFragment extends Fragment {

    private String mTitle;

    private static final String TAB_BUNDLE_TITLE="title";

    public static TabFragment newInstance(String title)
    {
        Bundle bundle=new Bundle();
        bundle.putString(TAB_BUNDLE_TITLE,title);
        TabFragment tabFragment=new TabFragment();
        tabFragment.setArguments(bundle);
        return tabFragment;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Bundle arguments = getArguments();

        if(arguments!=null)
        {
            mTitle=arguments.getString(TAB_BUNDLE_TITLE);
        }

        TextView textView=new TextView(container.getContext());
        textView.setText(mTitle);
        textView.setGravity(Gravity.CENTER);
        textView.setTextSize(TypedValue.COMPLEX_UNIT_SP,36);
        textView.setTextColor(Color.BLACK);
        return textView;
    }
}
